using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;

namespace UserService.HttpApi.Host.Filter;

internal class HideAbpEndpointsDocumentFilter : IDocumentFilter
{
    public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
    {
        var pathsToRemove = swaggerDoc.Paths
            .Where(path => path.Key.StartsWith("/api/abp/"))
            .ToList();
            
        foreach (var path in pathsToRemove)
        {
            swaggerDoc.Paths.Remove(path.Key);
        }
        
        /*var schemasToRemove = swaggerDoc.Components.Schemas
            .Where(x => x.Key.StartsWith("Volo.Abp"))
            .Select(x => x.Key)
            .ToList();
            
        foreach (var schema in schemasToRemove)
        {
            swaggerDoc.Components.Schemas.Remove(schema);
        }*/
    }
}